//
//  ChangePassViewController.swift
//  HuaYun
//
//  Created by enghou on 2018/12/14.
//  Copyright © 2018 xyxorigation. All rights reserved.
//

import UIKit

class ChangePassViewController: BaseTableViewController {

    var phone = ""
    var verficationCode = ""
    
    @IBOutlet weak var newPassWordField: UITextField!
    @IBOutlet weak var confirmPassWordField: UITextField!
    @IBAction func changeAction(_ sender: Any) {
    }
    
    override func path(for name: String) -> String {
        return ForgetPass
    }
    
    override func param(for name: String) -> Dictionary<String, Any> {
        return ["phone": self.phone,"password": (self.newPassWordField.text ?? ""),"confirmPwd": (self.confirmPassWordField.text ?? ""),"verficationCode": verficationCode]
    }
    
    override func strategy(for name: String) -> (Bool, String?, (() -> Void)?) {
        
        if phone.count == 0 {
            return (false,"无手机号!",nil)
        }
        if verficationCode.count == 0 {
            return (false,"验证码为空",nil)
        }
        if newPassWordField.text?.count == 0 {
            return (false,"请输入新的密码",nil)
        }
        if confirmPassWordField.text?.count == 0 {
            return (false,"请输入验证密码",nil)
        }
        if confirmPassWordField.text != newPassWordField.text {
            return (false,"请保证密码一致!",nil)
        }
        return (true,nil,nil)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Uncomment the following line to preserve selection between presentations
        // self.clearsSelectionOnViewWillAppear = false

        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem
    }

}
